/*
 * Copyright: Tianjin Berheley Tech Co,.ltd, China
 * biPlatForm
 * com.berheley.bi.beanProcess -> BeanPropertyTextAppender.java
 * Created on 2009-10-21-下午01:26:53
 */
package com.webframe.beanProcess;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.webframe.exception.JSException;


/**
 * 类功能描述：
 *
 * @author      <a href="mailto:tozxwu@hotmail.com">wuzhenxue </a>
 * Create:      2009-10-21 下午01:26:53
 * Description: 
 */
public class BeanPropertyTextAppender extends AbstractBeanPropertyProcessor {
	
	private static final Log log = LogFactory.getLog(BeanPropertyTextAppender.class);

	private String appended;
	
	protected Object getProcessedPropertyValue(Object originalValue) {
		String appendedValue;
		if (originalValue == null) {
			appendedValue = getAppended();
		} else {
			if (!(originalValue instanceof String)) {
				throw new JSException("jsexception.property.not.a.text", new Object[] {getPropertyName(), getBeanName()});
			}
			appendedValue = originalValue + getAppended();
		}
		
		if (log.isInfoEnabled()) {
			log.info("Appending " + getBeanName() + "." + getPropertyName() + " with " + getAppended());
		}
		
		return appendedValue;
	}

	public String getAppended() {
		return appended;
	}

	public void setAppended(String appendedText) {
		this.appended = appendedText;
	}

}
